<?php
class LinkAction extends BaseAction{

	public function index(){
		$Links = D("Link");
		import("ORG.Util.Page");

		$count = $Links->count();
		$Page = new Page($count,20);
		$Page -> parameter .= "keyword=".urlencode($kmap)."&";
		$show = $Page->show();
		$link = $Links->order('id desc')->limit($Page->firstRow.','.$Page->listRows)->select();
		$this->assign('pages',$show);
		$this->assign("link",$link);
                $this->assign("title",'友情链接');
		$this->display("Public:link");
	}
	public function add(){
		$this->display("Public:link");
	}
	public function doadd(){
                $data = $_POST;
		$Links = D("Link");
                $Links->Create();
		if($Links->add($data)){
			$this->success("添加成功！");
		}else{
			$this->error("添加失败！");
		}
	}
	public function edit(){
		if($_GET['id']){
			$Link = D("Link")->getById($_GET['id']);
			$this->assign($Link);

			$this->display("Public:link");
		}else{
			$this->assign("jumpUrl","__URL__");
			$this->error("数据不存在！");
		}
	}
	public function doedit(){
		$data = $_POST;
		if(D("Link")->save($data)){
			$this->success("修改成功！");
		}else{
			$this->error("修改失败！");
		}
	}
	public function batch(){
		$this->_batch();
	}
}
?>